package o;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import androidx.annotation.AttrRes;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.d;
import androidx.annotation.StyleRes;
import androidx.annotation.StyleableRes;
import o.aqu.n;

@RestrictTo({d.LIBRARY_GROUP})
public final class asa {
    private static final int[] ˊ = new int[]{aqu.d.ʼ};
    private static final int[] ॱ = new int[]{aqu.d.ᐝ};

    public static TypedArray ॱ(Context context, AttributeSet attributeSet, @StyleableRes int[] iArr, @AttrRes int i, @StyleRes int i2, @StyleableRes int... iArr2) {
        ˊ(context, attributeSet, i, i2);
        ˋ(context, attributeSet, iArr, i, i2, iArr2);
        return context.obtainStyledAttributes(attributeSet, iArr, i, i2);
    }

    public static cw ˏ(Context context, AttributeSet attributeSet, @StyleableRes int[] iArr, @AttrRes int i, @StyleRes int i2, @StyleableRes int... iArr2) {
        ˊ(context, attributeSet, i, i2);
        ˋ(context, attributeSet, iArr, i, i2, iArr2);
        return cw.ॱ(context, attributeSet, iArr, i, i2);
    }

    private static void ˊ(Context context, AttributeSet attributeSet, @AttrRes int i, @StyleRes int i2) {
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, n.ᵎॱ, i, i2);
        boolean z = obtainStyledAttributes.getBoolean(n.ᶥˋ, false);
        obtainStyledAttributes.recycle();
        if (z) {
            ˋ(context);
        }
        ˎ(context);
    }

    private static void ˋ(Context context, AttributeSet attributeSet, @StyleableRes int[] iArr, @AttrRes int i, @StyleRes int i2, @StyleableRes int... iArr2) {
        boolean z = false;
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, n.ᵎॱ, i, i2);
        if (obtainStyledAttributes.getBoolean(n.ᵢॱ, false)) {
            if (iArr2 != null && iArr2.length != 0) {
                z = ˊ(context, attributeSet, iArr, i, i2, iArr2);
            } else if (obtainStyledAttributes.getResourceId(n.ᴵॱ, -1) != -1) {
                z = true;
            }
            obtainStyledAttributes.recycle();
            if (!z) {
                throw new IllegalArgumentException("This component requires that you specify a valid TextAppearance attribute. Update your app theme to inherit from Theme.MaterialComponents (or a descendant).");
            }
            return;
        }
        obtainStyledAttributes.recycle();
    }

    private static boolean ˊ(Context context, AttributeSet attributeSet, @StyleableRes int[] iArr, @AttrRes int i, @StyleRes int i2, @StyleableRes int... iArr2) {
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, iArr, i, i2);
        for (int resourceId : iArr2) {
            if (obtainStyledAttributes.getResourceId(resourceId, -1) == -1) {
                obtainStyledAttributes.recycle();
                return false;
            }
        }
        obtainStyledAttributes.recycle();
        return true;
    }

    public static void ˎ(Context context) {
        ˊ(context, ॱ, "Theme.AppCompat");
    }

    public static void ˋ(Context context) {
        ˊ(context, ˊ, "Theme.MaterialComponents");
    }

    private static boolean ˊ(Context context, int[] iArr) {
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(iArr);
        boolean hasValue = obtainStyledAttributes.hasValue(0);
        obtainStyledAttributes.recycle();
        return hasValue;
    }

    private static void ˊ(Context context, int[] iArr, String str) {
        if (!ˊ(context, iArr)) {
            throw new IllegalArgumentException("The style on this component requires your app theme to be " + str + " (or a descendant).");
        }
    }
}
